package univ.bme.accounting.domain;

import java.util.Date;

import javax.persistence.Access;
import javax.persistence.AccessType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToOne;
import javax.persistence.Table;
import javax.persistence.JoinColumn;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

@Getter
@Setter
@NoArgsConstructor

@Entity
@Access(AccessType.FIELD)
@Table(name="comments")
public class Comment {
	
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private int id;
	
	@ManyToOne(targetEntity = User.class, fetch = FetchType.LAZY, optional = false )
	@Fetch( FetchMode.JOIN )
	@JoinColumn(name = "user_id")
	private User user;
	
	@ManyToOne(targetEntity = Transaction.class, fetch = FetchType.LAZY, optional = false )
	@Fetch( FetchMode.SELECT )
	@JoinColumn(name = "transaction_id")
	private Transaction transaction;
	
	@Column(nullable=false, length=500)
	private String text;
	
	@Column
	private Date date;
	
	
}
